import request from '@/config/axios'

import { SupplierSendOrderItemVO } from '@/api/erp/suppliersendorderitem'

// ERP采购入库审批单 VO
export interface PurchaseInOrderVO {
  id: string // 编号
  outOrderId: string // 随货同行单编号
  integrateId: string // 一级库整合单编号
  purchaseOrderId: string // 采购单编号-提交供应商采购单编号
  priInId: string // 一级库入库单编号
  supplierId: number // 供应商编号
  supplierName: string // 供应商名称
  opinion: string // 审批意见
  status: number // 状态
  processInstanceId: string // 流程实例的编号
  supplierSendOrderItems: Array<SupplierSendOrderItemVO> // 供应商发货单明细
}

// ERP采购入库审批单 API
export const PurchaseInOrderApi = {
  // 查询ERP采购入库审批单分页
  getPurchaseInOrderPage: async (params: any) => {
    return await request.get({ url: `/erp/purchase-in-order/page`, params })
  },

  // 查询ERP采购入库审批单详情
  getPurchaseInOrder: async (id: number) => {
    return await request.get({ url: `/erp/purchase-in-order/get?id=` + id })
  },

  // 新增ERP采购入库审批单
  createPurchaseInOrder: async (data: PurchaseInOrderVO) => {
    return await request.post({ url: `/erp/purchase-in-order/create`, data })
  },

  // 修改ERP采购入库审批单
  updatePurchaseInOrder: async (data: PurchaseInOrderVO) => {
    return await request.put({ url: `/erp/purchase-in-order/update`, data })
  },

  updatePurchaseInOrderReStatus: async (data: PurchaseInOrderVO) => {
    return await request.put({ url: `/erp/purchase-in-order/updatePurchaseInOrderReStatus`, data })
  },
  
  updateStatusPurchaseInOrder: async (data: PurchaseInOrderVO) => {
    return await request.put({ url: `/erp/purchase-in-order/updateStatus`, data })
  },

  // 删除ERP采购入库审批单
  deletePurchaseInOrder: async (id: number) => {
    return await request.delete({ url: `/erp/purchase-in-order/delete?id=` + id })
  },

  // 导出ERP采购入库审批单 Excel
  exportPurchaseInOrder: async (params) => {
    return await request.download({ url: `/erp/purchase-in-order/export-excel`, params })
  },
}
